//package cn.net.shuxing.yifu.common.service;
//
//import cn.net.shuxing.yifu.common.bean.DealHistory;
//import cn.net.shuxing.yifu.common.bean.HangBuy;
//import cn.net.shuxing.yifu.common.constant.DealScene;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.math.BigDecimal;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Service
//public class TransactionStatisticService {
//
//    @Autowired
//    private HangSaleService hangSaleService;
//
//    @Autowired
//    private HangBuyService hangBuyService;
//
//
//    @Autowired
//    private DealHistoryService dealHistoryService;
//
//
//    /** 挂买 **/
//
//    /**
//     * 获取用户累计挂买订单数
//     * @param userId
//     * @return
//     */
//    public Map<String,Integer> getUserTotalHangBuyCount(int userId)
//    {
//        Map<String, Integer> resultMap = new HashMap<>();
//        List<HangBuy> hangBuyList = hangBuyService.getTotalByUserId(userId);
//        int undealHangBuyCount = 0, dealingHangBuyCount = 0, dealedHangBuyCount = 0;
//        for (HangBuy hangBuy : hangBuyList)
//        {
//            Integer hangBuyId = hangBuy.getId();
//            List<DealHistory> dealHistoryList = dealHistoryService.getsByDealIdAndDealScene(hangBuyId, DealScene.HANG_BUY);
//            if (dealHistoryList == null || dealHistoryList.isEmpty())
//            {
//                undealHangBuyCount++;
//            }
//            else
//            {
//                BigDecimal dealedCount = new BigDecimal(0);
//                for (DealHistory dealHistory : dealHistoryList)
//                {
//                    dealedCount = dealedCount.add(dealHistory.getDealAliveCoinCount());
//                }
//                if (dealedCount == hangBuy.getAliveCoinCount())
//                {
//                    dealedHangBuyCount++;
//                }
//                else
//                {
//                    dealingHangBuyCount++;
//                }
//            }
//
//        }
//
//        resultMap.put("undealHangBuyCount",undealHangBuyCount);
//        resultMap.put("dealingHangBuyCount",dealingHangBuyCount);
//        resultMap.put("dealedHangBuyCount",dealedHangBuyCount);
//        return resultMap;
//    }
//
//    /**
//     * 获取用户今日挂买订单数
//     * @param userId
//     * @return
//     */
//    public Map<String,Integer> getUserTotalTodayBuyCount(int userId)
//    {
//        Map<String, Integer> resultMap = new HashMap<>();
//        List<HangBuy> hangBuyList = hangBuyService.getTodayByUserId(userId);
//        int undealHangBuyCount = 0, dealingHangBuyCount = 0, dealedHangBuyCount = 0;
//        for (HangBuy hangBuy : hangBuyList)
//        {
//            Integer hangBuyId = hangBuy.getId();
//            List<DealHistory> dealHistoryList = dealHistoryService.getsByDealIdAndDealScene(hangBuyId, DealScene.HANG_SALE);
//            if (dealHistoryList == null || dealHistoryList.isEmpty())
//            {
//                undealHangBuyCount++;
//            }
//            else
//            {
//                BigDecimal dealedCount = new BigDecimal(0);
//                for (DealHistory dealHistory : dealHistoryList)
//                {
//                    dealedCount = dealedCount.add(dealHistory.getDealAliveCoinCount());
//                }
//                if (dealedCount == hangBuy.getAliveCoinCount())
//                {
//                    dealedHangBuyCount++;
//                }
//                else
//                {
//                    dealingHangBuyCount++;
//                }
//            }
//
//        }
//
//        resultMap.put("undealHangBuyCount",undealHangBuyCount);
//        resultMap.put("dealingHangBuyCount",dealingHangBuyCount);
//        resultMap.put("dealedHangBuyCount",dealedHangBuyCount);
//        return resultMap;
//    }
//
//    /**
//     * 获取用户累计挂买订单总额
//     * @param userId
//     * @return
//     */
//    public Map<String,BigDecimal> getUserTotalHangBuyTotalAmount(int userId)
//    {
//        Map<String, BigDecimal> resultMap = new HashMap<>();
//        List<HangBuy> hangBuyList = hangBuyService.getTotalByUserId(userId);
//        BigDecimal undealHangBuyAmount = new BigDecimal(0), dealingHangBuyAmount = new BigDecimal(0), dealedHangBuyAmount = new BigDecimal(0);
//        for (HangBuy hangBuy : hangBuyList)
//        {
//            Integer hangBuyId = hangBuy.getId();
//            List<DealHistory> dealHistoryList = dealHistoryService.getsByDealIdAndDealScene(hangBuyId, DealScene.HANG_BUY);
//            if (dealHistoryList == null || dealHistoryList.isEmpty())
//            {
//                undealHangBuyAmount = undealHangBuyAmount.add(hangBuy.getAliveCoinCount());
//            }
//            else
//            {
//                BigDecimal dealedCount = new BigDecimal(0);
//                for (DealHistory dealHistory : dealHistoryList)
//                {
//                    dealedCount = dealedCount.add(dealHistory.getDealAliveCoinCount());
//                }
//                if (dealedCount == hangBuy.getAliveCoinCount())
//                {
//                    dealedHangBuyAmount = dealedHangBuyAmount.add(hangBuy.getAliveCoinCount());
//                }
//                else
//                {
//                    dealingHangBuyAmount = dealingHangBuyAmount.add(dealedCount);
//                }
//            }
//
//        }
//
//        resultMap.put("undealHangBuyAmount",undealHangBuyAmount);
//        resultMap.put("dealingHangBuyAmount",dealingHangBuyAmount);
//        resultMap.put("dealedHangBuyAmount",dealedHangBuyAmount);
//        return resultMap;
//    }
//
//    /**
//     * 获取用户今日挂买订单总额
//     * @param userId
//     * @return
//     */
//    public Map<String,BigDecimal> getUserTodayTodayBuyTotalAmount(int userId)
//    {
//        Map<String, BigDecimal> resultMap = new HashMap<>();
//        List<HangBuy> hangBuyList = hangBuyService.getTodayByUserId(userId);
//        BigDecimal undealHangBuyAmount = new BigDecimal(0), dealingHangBuyAmount = new BigDecimal(0), dealedHangBuyAmount = new BigDecimal(0);
//        for (HangBuy hangBuy : hangBuyList)
//        {
//            Integer hangBuyId = hangBuy.getId();
//            List<DealHistory> dealHistoryList = dealHistoryService.getsByDealIdAndDealScene(hangBuyId, DealScene.HANG_BUY);
//            if (dealHistoryList == null || dealHistoryList.isEmpty())
//            {
//                undealHangBuyAmount = undealHangBuyAmount.add(hangBuy.getAliveCoinCount());
//            }
//            else
//            {
//                BigDecimal dealedCount = new BigDecimal(0);
//                for (DealHistory dealHistory : dealHistoryList)
//                {
//                    dealedCount = dealedCount.add(dealHistory.getDealAliveCoinCount());
//                }
//                if (dealedCount == hangBuy.getAliveCoinCount())
//                {
//                    dealedHangBuyAmount = dealedHangBuyAmount.add(hangBuy.getAliveCoinCount());
//                }
//                else
//                {
//                    dealingHangBuyAmount = dealingHangBuyAmount.add(dealedCount);
//                }
//            }
//
//        }
//
//        resultMap.put("undealHangBuyAmount",undealHangBuyAmount);
//        resultMap.put("dealingHangBuyAmount",dealingHangBuyAmount);
//        resultMap.put("dealedHangBuyAmount",dealedHangBuyAmount);
//        return resultMap;
//    }
//
//
//
//
//    /** 成交 **/
//
//    /**
//     * 获取累计成交订单总额
//     * @return
//     */
//    public BigDecimal getTotalDealComletedTotalAmount()
//    {
//        List<DealHistory> dealHistoryList = dealHistoryService.getAll();
//        BigDecimal dealCompletedTotalAmount = new BigDecimal(0);
//        for (DealHistory dealHistory : dealHistoryList)
//        {
//            dealCompletedTotalAmount = dealCompletedTotalAmount.add(dealHistory.getDealAliveCoinCount());
//        }
//        return dealCompletedTotalAmount;
//    }
//
//    /**
//     * 获取今日成交订单总额
//     * @return
//     */
//    public BigDecimal getTodayDealComletedTotalAmount()
//    {
//        List<DealHistory> dealHistoryList = dealHistoryService.getByToday();
//        BigDecimal dealCompletedTotalAmount = new BigDecimal(0);
//        for (DealHistory dealHistory : dealHistoryList)
//        {
//            dealCompletedTotalAmount = dealCompletedTotalAmount.add(dealHistory.getDealAliveCoinCount());
//        }
//        return dealCompletedTotalAmount;
//    }
//
//    /**
//     * 获取累计成交订单量
//     * @return
//     */
//    public Integer getTotalDealComletedTotalCount()
//    {
//        return dealHistoryService.getAll().size();
//    }
//
//    /**
//     * 获取今日成交订单量
//     * @return
//     */
//    public Integer getTodayDealComletedTotalCount()
//    {
//        return dealHistoryService.getByToday().size();
//    }
//
//
//    /** 回购 **/
//
//    /**
//     * 获取累计回购订单总额
//     * @return
//     */
//    public BigDecimal getTotalBuyBackTotalAmount()
//    {
//        List<DealHistory> dealHistoryList = dealHistoryService.getTotalByBuyUserId(0);
//        BigDecimal dealCompletedTotalAmount = new BigDecimal(0);
//        for (DealHistory dealHistory : dealHistoryList)
//        {
//            dealCompletedTotalAmount =  dealCompletedTotalAmount.add(dealHistory.getDealAliveCoinCount());
//        }
//        return dealCompletedTotalAmount;
//    }
//
//    /**
//     * 获取今日回购订单总额
//     * @return
//     */
//    public BigDecimal getTdaylBuyBackTotalAmount()
//    {
//        List<DealHistory> dealHistoryList = dealHistoryService.getTodayByBuyUserId(0);
//        BigDecimal dealCompletedTotalAmount = new BigDecimal(0);
//        for (DealHistory dealHistory : dealHistoryList)
//        {
//            dealCompletedTotalAmount =  dealCompletedTotalAmount.add(dealHistory.getDealAliveCoinCount());
//        }
//        return dealCompletedTotalAmount;
//    }
//
//    /**
//     * 获取累计回购订单量
//     * @return
//     */
//    public Integer getTotalBuyBackTotalCount()
//    {
//        return dealHistoryService.getTotalByBuyUserId(0).size();
//    }
//
//    /**
//     * 获取今日回购订单量
//     * @return
//     */
//    public Integer getTodayBuyBackTotalCount()
//    {
//        return dealHistoryService.getTodayByBuyUserId(0).size();
//    }
//
//}
